<?php
namespace Popshouse\AdminBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Security\Core\SecurityContext;

use Popshouse\SiteBundle\Entity\Price;
use Popshouse\AdminBundle\Form\PricingForm;

class PricingController extends Controller
{
    /**
     * @extra:Template()
     */
    public function indexAction()
    {
    	$pricing = new Price();
        $form = $this->get('form.factory')->createNamed(new PricingForm(),'pricing',$pricing);
        $request = $this->get('request');
	    if ($request->getMethod() == 'POST') {
	        $form->bindRequest($request);
	        if ($form->isValid()) {
	        	//die($form->get('base')->getData());
	    		$pricing->save();
	    		
		        $this->get('session')->setFlash('notice', 'Prijzen opgeslaan');
	           	return new RedirectResponse($this->generateUrl('pricing'));
	        }
	    }
        return array('form' => $form->createView(), 'active' => 'pricing');
    }



}
